package com.n9.qqonline.api;

/**
 * 产品可售状态
 * 0：不可售、1：可售
 *
 * @author linyu
 * @date 2020-02-11
 */
public enum StockStatus {

    /**
     * 已售（不可售），该状态不可下单付款
     */
    UNSALE(0, "已售"),
    /**
     * 可售，该状态可下单付款，不可删除和修改法律状态
     */
    SALE(1, "可售"),
    /**
     * 预售，该状态不可下单付款
     */
    PRE_SALE(2, "预售"),
    /**
     * 已下架，该状态不可下单付款
     */
    SOLD_OUT(3, "已下架"),

    /**
     * 已预留，该状态可下单付款
     */
    RESERVING(4, "预定中");

    private int code;
    private String desc;

    StockStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static StockStatus valueOfCode(int code) {
        switch (code) {
            case 0:
                return UNSALE;
            case 1:
                return SALE;
            case 2:
                return PRE_SALE;
            case 3:
                return SOLD_OUT;
            case 4:
                return RESERVING;
            default:
                return null;
        }
    }

}
